import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FarmSaleVO, FarmSaleForm, FarmSaleQuery } from '@/api/erp/farmSale/types';

/**
 * 查询农场销售列表
 * @param query
 * @returns {*}
 */

export const listFarmSale = (query?: FarmSaleQuery): AxiosPromise<FarmSaleVO[]> => {
  return request({
    url: '/erp/farmSale/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农场销售详细
 * @param id
 */
export const getFarmSale = (id: string | number): AxiosPromise<FarmSaleVO> => {
  return request({
    url: '/erp/farmSale/' + id,
    method: 'get'
  });
};

/**
 * 新增农场销售
 * @param data
 */
export const addFarmSale = (data: FarmSaleForm) => {
  return request({
    url: '/erp/farmSale',
    method: 'post',
    data: data
  });
};

/**
 * 修改农场销售
 * @param data
 */
export const updateFarmSale = (data: FarmSaleForm) => {
  return request({
    url: '/erp/farmSale',
    method: 'put',
    data: data
  });
};

/**
 * 删除农场销售
 * @param id
 */
export const delFarmSale = (id: string | number | Array<string | number>) => {
  return request({
    url: '/erp/farmSale/' + id,
    method: 'delete'
  });
};
/**
 * 审核操作
 * @param data
 */
export const auditFarmSaleApi = (data: any) => {
  return request({
    url: `/erp/farmSale/audit`,
    method: 'put',
    data: data
  });
};
/**
 * 默认标题
 */
export const defaultTitle = () => {
  return request({
    url: `/erp/farmSale/title`,
    method: 'get'
  });
};
